//
//  XMActivityTableViewCell.m
//  XunMi
//
//  Created by MacBook on 2024/3/7.
//  Copyright © 2024 TieZhu. All rights reserved.
//

#import "XMActivityTableViewCell.h"
#import "XMActivityModel.h"

@interface XMActivityTableViewCell ()
@property (weak, nonatomic) IBOutlet UIImageView *imgV;
@property (weak, nonatomic) IBOutlet UILabel *titleLa;
@property (weak, nonatomic) IBOutlet UIButton *countBtn;
@property (weak, nonatomic) IBOutlet UILabel *stateLa;
@property (weak, nonatomic) IBOutlet UILabel *timeLa;

@end

@implementation XMActivityTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [_countBtn setImagePosition:XMImagePositionLeft spacing:6];
    kCornerRadius(_imgV, 6, 0, UIColor.clearColor);
    _stateLa.layer.mask = [UIView xm_viewClipRect:CGRectMake(0, 0, 70, 26) rectCorner:UIRectCornerTopLeft | UIRectCornerBottomLeft cornerRadii:CGSizeMake(13, 13)];
}

- (void)setModel:(XMActivityModel *)model {
    _model = model;
    [self.imgV sd_setImageWithURL:kStringToUrl(model.image.file_url) placeholderImage:kDefaultCoverImg];
    self.timeLa.text = kStringFormat(@"活动时间:%@", model.period);
    [self.countBtn setTitle:kStringFormat(@"%ld", model.click) forState:UIControlStateNormal];
    self.titleLa.text = model.title;
    /// 活动状态标识  1 未开始  2 进行中  3 已结束
    switch (model.status) {
        case 1:
            self.stateLa.text = @"未开始";
            self.stateLa.textColor = kHEX(@"#8C8F9D");
            self.stateLa.backgroundColor = kHEXA(@"#F5F6F7", 1);
            break;
            
        case 2:
            self.stateLa.text = @"进行中";
            self.stateLa.textColor = kHEX(@"#E74E63");
            self.stateLa.backgroundColor = kHEXA(@"#FFEFEF", 1);
            break;
            
        case 3:
            self.stateLa.text = @"已结束";
            self.stateLa.textColor = kHEX(@"#8C8F9D");
            self.stateLa.backgroundColor = kHEXA(@"#F5F6F7", 1);
            break;
        default:
            break;
    }
}





@end
